// 判断重复元素
const nums = [1, 2, 3, 1]
// 输出：true

var containsDuplicate1 = function (nums) {
  // 使用map
  let map = {};
  nums.forEach(e => {
    debugger
    if (map[e]) {
      map[e]++;
    } else {
      map[e] = 1;
    }
  })
  debugger
  let flag = false;
  Object.entries(map).forEach(([key, val]) => {
    if (val > 1) {
      flag = true;
    }
  })
  return flag;
};

// 使用set

var containsDuplicate = function (nums) {
  let set = new Set(nums);
  console.log('wwww',set.size);
  return set.size !== nums.length;
};



console.log(containsDuplicate(nums));